<script setup>
import PostItem from "../components/PostItem.vue";
import PostList from "../components/PostList.vue";
import { useStore } from "vuex";
import { useRoute } from "vue-router";
import { computed } from "vue";
//返回参数
const route = useRoute();
const term = computed(() => {
  route.params.term;
});

//返回搜索结果
const store = useStore();
const posts = computed(() => {
  return store.state.post.searchTerm;
});
</script>
<template>
  <div>
    <h2 class="title">搜索结果：{{ term }}</h2>
    <PostList>
      <PostItem v-for="item in posts" :post="item"></PostItem>
    </PostList>
  </div>
</template>

<style scoped>
.title {
  font-weight: 600;
  font-size: 24px;
  margin-bottom: 44px;
}
</style>
